package com.zhouyy.common.bean;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.util.Date;

/**
 * <p> 数据基础类型字段 </p>
 *
 * @author zhouyy
 * @description
 * @date 2024/03/25 19:21
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseEntity implements Serializable {
    /**
     * 强制每个表都要有个唯一id字段
     * 默认是自增id
     */
    @TableId(type = IdType.AUTO)
    @ApiModelProperty("id")
    private Long id;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 创建者的id
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    @JsonIgnore
    @ApiModelProperty(hidden = true)
    private Long createBy;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_Time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 更新者的id
     * 新增和更新执行
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    @JsonIgnore
    @ApiModelProperty(hidden = true)
    private Long updateBy;

    /**
     * 虚假删除标志字段, 0为正常, 1表示已删除
     */
    @TableLogic
    @JsonIgnore
    @ApiModelProperty(hidden = true)
    @TableField(value = "flag", fill = FieldFill.UPDATE)
    private Integer flag;
}
